package ${package.Controller};


<#--import org.springframework.web.bind.annotation.RequestMapping;-->

<#--<#if restControllerStyle>-->
<#--import org.springframework.web.bind.annotation.RestController;-->
<#--<#else>-->
<#--import org.springframework.stereotype.Controller;-->
<#--</#if>-->
<#--<#if superControllerClassPackage??>-->
<#--import ${superControllerClassPackage};-->
<#--</#if>-->

import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
@Api(value = "${entity?uncap_first}",description = "${table.comment!}")
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Autowired
    private ${table.serviceName} ${table.serviceName?uncap_first};

    @ApiOperation(value = "单个查询")
    @GetMapping("/query")
    public Object query(@ApiParam(value = "id", required = true) @RequestParam() String id) {
        return ${table.serviceName?uncap_first}.getById(id);
    }

    @ApiOperation(value = "单个删除")
    @PostMapping("/delete")
    public Object delete(@ApiParam(value = "id", required = true) @RequestParam() String id) {
        return ${table.serviceName?uncap_first}.removeById(id);
    }

    @ApiOperation(value = "单个新增")
    @PostMapping("/insert")
    public Object create(@RequestBody ${entity} ${entity?uncap_first}) {
        return ${table.serviceName?uncap_first}.save(${entity?uncap_first});
    }

    @ApiOperation(value = "单个更新")
    @PostMapping("/update")
    public Object update(@RequestBody ${entity} ${entity?uncap_first}) {
        return ${table.serviceName?uncap_first}.updateById(${entity?uncap_first});
    }


}
</#if>
